# -*- coding:utf-8 -*-
"""
作者：谷台阳
日期：2022年10月28日
"""
from skimage import feature as ft
import cv2
import matplotlib.pyplot as plt
import time
import os

os.mkdir("hog")
start = time.perf_counter()
for i in range(1, 9951):
    img = cv2.imread('../data/image_message/im{}.jpg'.format(10000 + i), cv2.IMREAD_GRAYSCALE)
    features = ft.hog(img, orientations=6, pixels_per_cell=[20, 20], cells_per_block=[2, 2], visualize=True)
    plt.imshow(features[1], cmap=plt.cm.gray)
    # plt.show()
    # print(len(features[1][0]))
    # cv2.imshow("f", features[1])
    cv2.imwrite("hog/{}.jpg".format(10000 + i), features[1])
    # cv2.waitKey(0)

    last = time.perf_counter() - start
    c = int(i / 9950 * 100)
    a = "*" * c
    b = "-" * (100 - c)
    print("\r{:^3.0f}%[{}->{}]{:.2f}s".format(c, a, b, last), end="")
